<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <script>
            function sendAjax(url){
                return new Promise((resolve,reject)=>{
                    const xhr = new XMLHttpRequest();
                    xhr.open("GET",url);
                    xhr.send();
                    xhr.onreadystatechange = ()=>{
                        if(xhr.readyState === 4){
                            if(xhr.status >= 200 && xhr.status <300){
                                resolve(xhr.response);
                            }else{
                                reject(xhr.status);
                            };
                        };
                    };
                });
            };
            
            async function main(){
                let result = await sendAjax("https://api.apiopen.top/getJoke");
                console.log(result);
            };
            main();
        </script>
    </body>
</html>